import { User } from 'src/user/entities/user.entity'
import {
  Column,
  CreateDateColumn,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn
} from 'typeorm'

@Entity('logger')
export class Logger {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ length: 255 })
  name: string

  @Column({ length: 255, nullable: true })
  param: string

  @Column({ name: 'user_id' })
  userId: number

  @Column({ name: 'user_name', length: 255 })
  userName: string

  @Column({ length: 45 })
  ip: string

  @Column({ length: 10 })
  method: string

  @Column({ length: 255 })
  url: string

  @Column({ name: 'user_agent' })
  userAgent: string

  @Column({ name: 'status_code' })
  statusCode: number

  @Column({ name: 'response_time' })
  responseTime: number

  @Column({ name: 'response_data' })
  responseData: string

  @CreateDateColumn({
    type: 'timestamp',
    name: 'create_time',
    nullable: false
  })
  createTime: Date

  constructor(logger?: Partial<Logger>) {
    Object.assign(this, logger)
  }
}
